﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Log4Net Database Viewer</title>
</head>
<body>
<strong>Log4Net Database Viewer</strong>
    <form id="form1" runat="server">
    <div>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
            HeaderText="The following excpetions were found:" ShowMessageBox="True" 
            ValidationGroup="Filter" />
    <table>
        <tr>
        <td>ID</td>
        <td colspan="2">
            Between         <asp:TextBox ID="IdStartTextBox" runat="server" Width="48px" 
                ValidationGroup="Filter"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator1" runat="server" 
                ControlToValidate="IdStartTextBox" ErrorMessage="Minimum ID must be a number" 
                Operator="DataTypeCheck" SetFocusOnError="True" Type="Integer" 
                ValidationGroup="Filter">!</asp:CompareValidator>
        and <asp:TextBox ID="IdEndTextBox" runat="server" Width="48px" 
                ValidationGroup="Filter"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator2" runat="server" 
                ControlToValidate="IdEndTextBox" ErrorMessage="Maximum ID must be a number" 
                Operator="DataTypeCheck" SetFocusOnError="True" Type="Integer" 
                ValidationGroup="Filter">!</asp:CompareValidator>
        </td>
        <td>Thread</td>
        <td><asp:DropDownList ID="ThreadDropDownList" runat="server" 
                ValidationGroup="Filter">
            <asp:ListItem Selected="True">Begins with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t begin with</asp:ListItem>
            <asp:ListItem>Contains</asp:ListItem>
            <asp:ListItem>Doesn&#39;t contain</asp:ListItem>
            <asp:ListItem>Ends with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t end with</asp:ListItem>
            <asp:ListItem>Matches</asp:ListItem>
            <asp:ListItem>Doesn&#39;t match</asp:ListItem>
        </asp:DropDownList></td>
        <td><asp:TextBox ID="ThreadTextBox" runat="server" Width="327px" 
                ValidationGroup="Filter"></asp:TextBox></td>
        </tr>
        <tr>
        <td>Date</td>
        <td colspan="2">
        From
        <asp:TextBox ID="DateStartTextBox" runat="server" ValidationGroup="Filter"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator3" runat="server" 
                ControlToValidate="DateStartTextBox" 
                ErrorMessage="Minimum date must a valid date." Operator="DataTypeCheck" 
                SetFocusOnError="True" Type="Date" ValidationGroup="Filter">!</asp:CompareValidator>
&nbsp;to&nbsp;
        <asp:TextBox ID="DateEndTextBox" runat="server" ValidationGroup="Filter"></asp:TextBox>
            <asp:CompareValidator ID="CompareValidator4" runat="server" 
                ControlToValidate="DateEndTextBox" 
                ErrorMessage="Maximum date must a valid date." Operator="DataTypeCheck" 
                SetFocusOnError="True" Type="Date" ValidationGroup="Filter">!</asp:CompareValidator>
        </td>
        
                
        <td>Logger</td>
        <td><asp:DropDownList ID="LoggerDropDownList" runat="server" 
                ValidationGroup="Filter">
            <asp:ListItem Selected="True">Begins with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t begin with</asp:ListItem>
            <asp:ListItem>Contains</asp:ListItem>
            <asp:ListItem>Doesn&#39;t contain</asp:ListItem>
            <asp:ListItem>Ends with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t end with</asp:ListItem>
            <asp:ListItem>Matches</asp:ListItem>
            <asp:ListItem>Doesn&#39;t match</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
        <asp:TextBox ID="LoggerTextBox" runat="server" Width="327px" 
                ValidationGroup="Filter"></asp:TextBox>
        </td>
        </tr>
        <tr>
        <td rowspan="2">Levels</td>
        <td rowspan="2" colspan="2">
                <asp:CheckBox ID="FatalCheckBox" runat="server" Checked="True" 
                    Text="Fatal Error" ValidationGroup="Filter" />
        <asp:CheckBox ID="ErrorCheckBox" runat="server" Checked="True" Text="Error" 
                    ValidationGroup="Filter" />
        <asp:CheckBox ID="WarnCheckBox" runat="server" Text="Warning" Checked="True" 
                    ValidationGroup="Filter" />
                <br />
        <asp:CheckBox ID="InfoCheckBox" runat="server" Text="Information" Checked="True" 
                    ValidationGroup="Filter" />
        <asp:CheckBox ID="DebugCheckBox" runat="server" Text="Debug" Checked="True" 
                    ValidationGroup="Filter" />
        </td>
        <td>
        Message
        <td><asp:DropDownList ID="MessageDropDownList" runat="server" 
                ValidationGroup="Filter">
            <asp:ListItem Selected="True">Begins with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t begin with</asp:ListItem>
            <asp:ListItem>Contains</asp:ListItem>
            <asp:ListItem>Doesn&#39;t contain</asp:ListItem>
            <asp:ListItem>Ends with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t end with</asp:ListItem>
            <asp:ListItem>Matches</asp:ListItem>
            <asp:ListItem>Doesn&#39;t match</asp:ListItem>
        </asp:DropDownList></td>
        <td><asp:TextBox ID="MessageTextBox" runat="server" Width="327px" 
                ValidationGroup="Filter"></asp:TextBox></td></tr>
        <tr>
        <td>Exception</td>
        <td><asp:DropDownList ID="ExceptionDropDownList" runat="server" 
                ValidationGroup="Filter">
            <asp:ListItem Selected="True">Begins with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t begin with</asp:ListItem>
            <asp:ListItem>Contains</asp:ListItem>
            <asp:ListItem>Doesn&#39;t contain</asp:ListItem>
            <asp:ListItem>Ends with</asp:ListItem>
            <asp:ListItem>Doesn&#39;t end with</asp:ListItem>
            <asp:ListItem>Matches</asp:ListItem>
            <asp:ListItem>Doesn&#39;t match</asp:ListItem>
        </asp:DropDownList></td>
        <td><asp:TextBox ID="ExceptionTextBox" runat="server" Width="327px" 
                ValidationGroup="Filter"></asp:TextBox></td></tr>
        </table>
        <table style="width:100%">
        <tr>
        <td>
        <asp:Button ID="ApplyFilterButton" runat="server" Text="Apply Filter" 
                onclick="ApplyFilterButton_Click" ValidationGroup="Filter" />
        </td>
        <td style="text-align:center">
            <asp:Label ID="MatchLabel" runat="server" Text="0"></asp:Label>
&nbsp;Matches
        </td>
        <td style="text-align:right">Page Size
            <asp:DropDownList ID="PageSizeDropDownList" runat="server" AutoPostBack="True" 
                onselectedindexchanged="PageSizeDropDownList_SelectedIndexChanged">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>15</asp:ListItem>
                <asp:ListItem Selected="True">20</asp:ListItem>
                <asp:ListItem>25</asp:ListItem>
                <asp:ListItem>30</asp:ListItem>
                <asp:ListItem>40</asp:ListItem>
                <asp:ListItem>50</asp:ListItem>
                <asp:ListItem>75</asp:ListItem>
                <asp:ListItem>100</asp:ListItem>
                <asp:ListItem>200</asp:ListItem>
            </asp:DropDownList>
        </td></tr></table>
        
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" 
            DataSourceID="ObjectDataSource1" CellPadding="4" DataKeyNames="Id" 
            ForeColor="#333333" GridLines="None" Width="100%" Font-Size="Smaller" 
            PageSize="20" onrowdeleted="GridView1_RowDeleted">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                    SortExpression="Id" />
                <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
                <asp:BoundField DataField="Thread" HeaderText="Thread" 
                    SortExpression="Thread" />
                <asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" />
                <asp:BoundField DataField="Logger" HeaderText="Logger" 
                    SortExpression="Logger" ReadOnly="True" />
                <asp:BoundField DataField="Message" HeaderText="Message" 
                    SortExpression="Message" ReadOnly="True" />
                <asp:BoundField DataField="Exception" HeaderText="Exception" 
                    SortExpression="Exception" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <EmptyDataTemplate>
                    No records matched your query.
                </EmptyDataTemplate>
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        
            <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource2" 
                DataKeyNames="Id" onitemdeleted="FormView1_ItemDeleted">
               
                <ItemTemplate>
                
                <table><tr><td>
                    <b>Id:</b></td><td><%#Eval("Id")%></td></tr>
                    <tr><td valign="top"><b>Date:</b></td><td><%# Eval("Date", "{0:F}") %></td></tr>
                    <tr><td valign="top"><b>Thread:</b></td><td><%# Eval("Thread") %></td></tr>
                    <tr><td valign="top"><b>Level:</b></td><td><%# Eval("Level") %></td></tr>
                    <tr><td valign="top"><b>Logger:</b></td><td><%# Eval("Logger") %></td></tr>
                    <tr><td valign="top"><b>Message:</b></td><td><%# Eval("Message") == null ? string.Empty : Server.HtmlEncode((string)Eval("Message")).Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\r\n", "<br />").Replace("\r", "<br />").Replace("\n", "<br />") %></td></tr>
                    <tr><td valign="top"><b>Exception:</b></td><td><%# Eval("Exception") == null ? string.Empty : Server.HtmlEncode((string)Eval("Exception")).Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\r\n", "<br />").Replace("\r", "<br />").Replace("\n", "<br />")%></td></tr>
                    </table>
                    <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete" />
                </ItemTemplate>
            </asp:FormView>
            
            <hr />
        <asp:Button ID="DeleteAllButton" runat="server" Text="Delete All Logs" 
                OnClientClick="return confirm('This will delete everything!\r\nAre you sure?');" 
                onclick="DeleteAllButton_Click" />
            
            <br />
            <br />
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                DeleteMethod="Delete" OldValuesParameterFormatString="original_{0}" 
                SelectMethod="GetDataById" 
                TypeName="WebApplication.Log4NetDataSetTableAdapters.LogTableAdapter">
                <DeleteParameters>
                    <asp:Parameter Name="Original_Id" Type="Int32" />
                </DeleteParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="Id" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <br />
        
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            DeleteMethod="Delete" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetData" 
            TypeName="WebApplication.Log4NetDataSetTableAdapters.LogTableAdapter" EnablePaging="True" 
            SelectCountMethod="Count" SortParameterName="sort" 
                onselected="ObjectDataSource1_Selected">
            <DeleteParameters>
                <asp:Parameter Name="Original_Id" Type="Int32" />
            </DeleteParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="IdStartTextBox" Name="StartId" 
                    PropertyName="Text" Type="Int32" />
                <asp:ControlParameter ControlID="IdEndTextBox" Name="EndId" PropertyName="Text" 
                    Type="Int32" />
                <asp:ControlParameter ControlID="DateStartTextBox" 
                    Name="StartDate" PropertyName="Text" Type="DateTime" />
                <asp:ControlParameter ControlID="DateEndTextBox" Name="EndDate" 
                    PropertyName="Text" Type="DateTime" />
                <asp:ControlParameter ControlID="ThreadDropDownList" Name="ThreadCondition" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ThreadTextBox" Name="Thread" 
                    PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="FatalCheckBox" Name="ShowFatal" 
                    PropertyName="Checked" Type="Boolean" />
                <asp:ControlParameter ControlID="ErrorCheckBox" Name="ShowError" 
                    PropertyName="Checked" Type="Boolean" />
                <asp:ControlParameter ControlID="InfoCheckBox" Name="ShowWarn" 
                    PropertyName="Checked" Type="Boolean" />
                <asp:ControlParameter ControlID="InfoCheckBox" Name="ShowInfo" 
                    PropertyName="Checked" Type="Boolean" />
                <asp:ControlParameter ControlID="DebugCheckBox" Name="ShowDebug" 
                    PropertyName="Checked" Type="Boolean" />
                <asp:ControlParameter ControlID="LoggerDropDownList" Name="LoggerCondition" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="LoggerTextBox" Name="Logger" 
                    PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="MessageDropDownList" Name="MessageCondition" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="MessageTextBox" Name="Message" 
                    PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="ExceptionDropDownList" 
                    Name="ExceptionCondition" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ExceptionTextBox" Name="Exception" 
                    PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="GridView1" Name="Sort" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="GridView1" Name="StartRowIndex" 
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="GridView1" Name="MaximumRows" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
            <br />
        
        
        
        
    </div>
    </form>
</body>
</html>
